﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using RGB.SharePoint.Util.EmailUtility;
using System.Collections.Generic;

namespace RGB.SharePoint.Util.TestEmailUtility
{
	public partial class TestEmailConfigurationUserControl : UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
		}

		protected void FindEmailButton_Click(object sender, EventArgs e)
		{
			EmailConfigurationManager emailManager = new EmailConfigurationManager();
			IDictionary<string, string> properties = new Dictionary<string, string>();
			properties.Add("UserName", "Rahul Babar");
			EmailTemplate email = emailManager.GetEmailTemplate(EmailTemplateIdTextBox.Text.Trim(), null, properties);
			if (email != null)
			{
				EmailTemplateSubjectLabel.Text = email.EmailTemplateSubject;
				EmailTemplateBodyLabel.Text = email.EmailTemplateBody;
				ShortDescriptionLabel.Text = email.ShortDescription;
				MessageLabel.Text = "Email Retrieved Successfully.";
			}
			else
			{
				MessageLabel.Text = "Email Template not found.";
				EmailTemplateSubjectLabel.Text = "";
				EmailTemplateBodyLabel.Text = "";
			}
		}
	}
}
